<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./OL_SDK/include-openlayers-local.js"></script>
    <script src="./libs/gaode.js"></script>
</head>

<body>
    <div id="map">
    </div>
    <script>
        var map = new ol.Map({
            target: "map",
            layers: [gaode],
            view: new ol.View({
                projection: 'EPSG:4326',
                center: [114.30, 30.50],
                zoom: 4
            })
        })
        const style = new ol.style.Style({
            //填充色
            fill: new ol.style.Fill({
                // color: 'rgba(255, 255, 255, 0.8)'
                color: 'green'
            }),
            //边线颜色
            stroke: new ol.style.Stroke({
                color: 'red',
                width: 2
            }),
            //形状
            image: new ol.style.Circle({
                radius: 8,
                fill: new ol.style.Fill({
                    color: '#ffcc3367'
                }),
                stroke: new ol.style.Stroke({
                    color: '#333',
                    width: 2
                })
            })
        })
        var data = {
            type: "FeatureCollection",
            features: [
                /* 点 */
                {
                    type: "Feature",
                    geometry: {
                        type: "Point",
                        coordinates: [114.30, 30.50]
                    }
                },
                /* 线 */
                {
                    type: "Feature",
                    geometry: {
                        type: "LineString",
                        coordinates: [[114.30, 30.50], [114.30, 26]]
                    }
                },
                /* 区 */
                {
                    type: "Feature",
                    geometry: {
                        type: "Polygon",
                        coordinates: [
                            [
                                [114.30, 30.50],
                                [116, 30.50],
                                [116, 35]
                            ]
                        ]
                    }
                }
            ]
        }
        var features = new ol.format.GeoJSON().readFeatures(data);
        // new ol.format.GeoJSON()先计算 
        // 然后再 geo_format.readFeatures(data)
        console.log(features)// [e,e,e]
        var source = new ol.source.Vector({
            features
        })
        var layer = new ol.layer.Vector({
            source,
            style
        })
        map.addLayer(layer)
    </script>
</body>

</html>